Developer --> Technical Publications
PATHJava Developer Documentation > Mac OS Runtime for Java > JManager > Programming With JManager


Displaying Frames

As explained earlier, a Java program displays graphical output in virtual windows called frames. Since frames correspond to Mac OS windows, you can manipulate them in a similar manner (for example, create or destroy frames, resize them, and so on).

In order to communicate between the abstract frames and the actual Mac OS windows, you must designate a number of application-defined callback functions. Many of these functions correspond to similar Mac OS Toolbox functions. The application-defined functions and their corresponding Mac OS Toolbox functions are shown in Table 1-1. For details of the structure of these functions, see Application-Defined Functions.

Table 1-1 Application-defined frame functions

Frame function

Description

Corresponding Mac OS Toolbox function

MyRequestFrame Creates a new window GetNewCWindow , NewCWindow , GetNewWindow , or NewWindow
MyReleaseFrame Disposes of a window DisposeWindow
MyResizeRequest Requests that a window be resized SizeWindow
MyInvalRect Invalidates a portion of a window InvalRect
MyShowHide Shows or hides a window ShowHide or ShowWindow and HideWindow
MySetTitle Sets the window title bar SetWTitle
MyCheckUpdate Checks to see if a window update is necessary CheckUpdate or BeginUpdate and EndUpdate
MyFrameReorder Changes the ordering of the frame (bring to front, send to back, etc) BringToFront or SendBehind
MySetResizeable Sets whether a frame is resizeable or not No corresponding function, although the state set by this function affects whether your DoGrowWindow callback calls the SizeWindow function.

Typically the bulk of an application-defined frame function prepares a call to the corresponding Mac OS Toolbox function. For example, assuming that the application uses the functions in Listing 1-8 and Listing 1-9, you can use the callback function in Listing 1-10 to set the window title.

Listing 1-10 A callback function to change the title of a window

void MySetTitle(JMFrameRef frame, JMTextRef titleObj)
{
    Handle title;
    Str255 ptitle;

    title = JMTextToMacOSCStringHandle(titleObj);
    Hlock(title);

    convertToPascalString(*title, &ptitle); /* this is a dummy utility */

    WindowPtr win = getFrameWindow(frame);
    if (win)
        SetWTitle(win, ptitle);

    HUnlock(title);
    DisposeHandle(title);
}

Since the Mac OS Toolbox function SetWTitle requires a Pascal string, you must convert the handle title before calling SetWTitle .


© 1998 Apple Computer, Inc. — (Last Updated 3 Dec 98)

Previous | Back Up One Level | Next |